# find_package(MKL)
find_package(Eigen2)
if (EIGEN2_FOUND)

  include_directories(${EIGEN2_INCLUDE_DIR})
  btl_add_bench(btl_eigen2_linear main_linear.cpp)
  btl_add_bench(btl_eigen2_vecmat main_vecmat.cpp)
  btl_add_bench(btl_eigen2_matmat main_matmat.cpp)
  btl_add_bench(btl_eigen2_adv main_adv.cpp)

  IF(NOT BTL_NOVEC)
    btl_add_bench(btl_eigen2_novec_linear main_linear.cpp)
    btl_add_bench(btl_eigen2_novec_vecmat main_vecmat.cpp)
    btl_add_bench(btl_eigen2_novec_matmat main_matmat.cpp)
    btl_add_bench(btl_eigen2_novec_adv main_adv.cpp)
    if(BUILD_btl_eigen2_novec_linear)
      set_target_properties(btl_eigen2_novec_linear PROPERTIES COMPILE_FLAGS "-DEIGEN_DONT_VECTORIZE")
    endif(BUILD_btl_eigen2_novec_linear)
    if(BUILD_btl_eigen2_novec_vecmat)
      set_target_properties(btl_eigen2_novec_vecmat PROPERTIES COMPILE_FLAGS "-DEIGEN_DONT_VECTORIZE")
    endif(BUILD_btl_eigen2_novec_vecmat)
    if(BUILD_btl_eigen2_novec_matmat)
      set_target_properties(btl_eigen2_novec_matmat PROPERTIES COMPILE_FLAGS "-DEIGEN_DONT_VECTORIZE")
    endif(BUILD_btl_eigen2_novec_matmat)
    if(BUILD_btl_eigen2_novec_adv)
      set_target_properties(btl_eigen2_novec_adv PROPERTIES COMPILE_FLAGS "-DEIGEN_DONT_VECTORIZE")
    endif(BUILD_btl_eigen2_novec_adv)

#     if(BUILD_btl_eigen2_adv)
#       target_link_libraries(btl_eigen2_adv ${MKL_LIBRARIES})
#     endif(BUILD_btl_eigen2_adv)
    
  ENDIF(NOT BTL_NOVEC)

  btl_add_bench(btl_tiny_eigen2 btl_tiny_eigen2.cpp OFF)

  IF(NOT BTL_NOVEC)
    btl_add_bench(btl_tiny_eigen2_novec btl_tiny_eigen2.cpp OFF)
    if(BUILD_btl_tiny_eigen2_novec)
      set_target_properties(btl_tiny_eigen2_novec PROPERTIES COMPILE_FLAGS "-DEIGEN_DONT_VECTORIZE")
    endif(BUILD_btl_tiny_eigen2_novec)
  ENDIF(NOT BTL_NOVEC)
  
endif (EIGEN2_FOUND)
